﻿using System.Linq;
using Styx.WoWInternals.WoWObjects;

namespace ChiWalker.Helpers
{
    internal class HealUnit
    {
        public static WoWUnit Tank
        {
            get
            {
                return Group.PartyMembersCache.OrderBy(u => u.HealthPercent).FirstOrDefault(u => u.IsAlive && IsTank(u));
            }
        }

        public static WoWUnit LowestHealth
        {
            get { return Group.PartyMembersCache.OrderBy(u => u.HealthPercent).FirstOrDefault(u => u.IsAlive); }
        }

        private static bool IsTank(WoWUnit unit)
        {
            return
                Group.GroupMembers.FirstOrDefault(o => o.Guid == unit.Guid && o.Role == WoWPartyMember.GroupRole.Tank) !=
                null;
        }
    }
}